package BehavioralPattern.ChainOfResp;

/**
 * @Classname : ConcreteHandler
 * @Description : 具体处理者
 * @Author : chentianyu
 * @Date 2023/3/5 11:12
 */

// 审批领导：小组负责人
class GroupLeader extends Handler {

    private String name;

    public GroupLeader(String name) {
        this.name = name;
    }

    @Override
    protected boolean isResponsible(Request request) {
        return request.getType() <= 3;  // 小组负责人负责审批 (0, 3] 天的请假
    }

    @Override
    protected void response(Request request) {
        System.out.println("请假天数【" + request.getType() + "】属于区间 (0, 3] ，小组负责人【" + this.name + "】审批通过");
    }
}


// 审批领导：中心负责人
class CentreLeader extends Handler {

    private String name;

    public CentreLeader(String name) {
        this.name = name;
    }

    @Override
    protected boolean isResponsible(Request request) {
        return 3 < request.getType() && request.getType() <= 7;  // 中心负责人负责审批 (3, 7] 天的请假
    }

    @Override
    protected void response(Request request) {
        System.out.println("请假天数【" + request.getType() + "】属于区间 (3, 7] ，中心负责人【" + this.name + "】审批通过");
    }
}


// 审批领导：部门负责人
class DeptLeader extends Handler {

    private String name;

    public DeptLeader(String name) {
        this.name = name;
    }

    @Override
    protected boolean isResponsible(Request request) {
        return 7 < request.getType() && request.getType() <= 30;  // 部门负责人负责审批 (7, 30] 天的请假
    }

    @Override
    protected void response(Request request) {
        System.out.println("请假天数【" + request.getType() + "】属于区间 (7, 30] ，部门负责人【" + this.name + "】审批通过");
    }
}
